<?php
class resource_link_concept extends system_concept_abstract {
	
	public function init() {
		$this->setModel('resource_link_model', 'link');
		$this->setModelCols('link', array('key', 'url'));
	}

	public function save($row) {
		if(!$row->getUrl()) {
			throw new resource_exception("URL is Empty.");
		}
		$key = system_encrypt::shortUrl($row->getUrl());
		if(!$this->fetch(array('`key` = ?' => $key))) {
			$this->getModel('link')->insert($row->getModelData('link'));
		}
		return $row;
	}
	
	public function delete($row) {
		return ;
	}

}